#include<iostream>
using namespace std;
int main()
{
	int kids[5];
	int sum = 0;
	for (int i = 0;i < 5;i++)
	{
		cin >> kids[i];
	}
	for (int i = 0;i < 5;i++)
	{
		if (i == 0)
		{
			kids[4 - i] = kids[4 - i] + kids[i] / 3;
			kids[i + 1] = kids[i + 1] + kids[i] / 3;
			sum = sum + kids[i] % 3;
			kids[i] = kids[i] / 3;
		}
		else if (i == 4)
		{
			kids[4 - i] = kids[4 - i] + kids[i] / 3;
			kids[i - 1] = kids[i - 1] + kids[i] / 3;
			sum = sum + kids[i] % 3;
			kids[i] = kids[i] / 3;
		}
		else
		{
			kids[i + 1] = kids[i + 1] + kids[i] / 3;
			kids[i - 1] = kids[i - 1] + kids[i] / 3;
			sum = sum + kids[i] % 3;
			kids[i] = kids[i] / 3;
		}
	}
	for (int i = 0;i < 5;i++)
	{
		cout << kids[i] << " ";
	}
	cout << endl;
	cout << sum;
	return 0;
}